<?php $this->headTitle('Administrator');  ?>

<?php if(!empty($this->returnMessageSuccess)): ?>
<div class="success"><?php echo $this->escape($this->returnMessageSuccess[0]); ?></div>
<?php endif; ?>

<?php if(!empty($this->returnMessageWarning)): ?>
<div class="warning"><?php echo $this->escape($this->returnMessageWarning[0]); ?></div>
<?php endif; ?>

<div class="box">
  <div class="left"></div>
  <div class="right"></div>
  <div class="heading">
    <h1 style="background-image: url('images/user.png');">Administrator</h1>
    <div class="buttons">
        <a onclick="location = '<?php echo $this->url(array('do'=>'insert'),'administratorAdministrator',true); ?>'" class="button"><span>Insert</span></a>
        <a class="button" id="delete"><span>Delete</span></a>
    </div>
  </div>
  <div class="content">
      <form action="<?php echo $this->url(array('do'=>'delete'),'administratorAdministrator',true); ?>" method="post" enctype="multipart/form-data" id="form" autocomplete="off">
      <input type="hidden" name="redir" value="<?php echo $this->requestUri(); ?>">
      <table class="list">
        <thead>
          <tr>
           <td width="1" style="text-align: center;"><input type="checkbox" onclick="$('input[name*=\'selected\']').attr('checked', this.checked);" /></td>
            <td class="left">
                <?php if((isset($this->data['sort'])) && ($this->data['sort'] == 'surname')): ?>
                <a href="<?php echo $this->url(array('do'=>'access'),'administratorAdministrator',true). "?sort=surname". $this->partHeadUrl; ?>" class="<?php echo strtolower($this->data['order']); ?>">Surname</a>
                <?php else: ?>
                <a href="<?php echo $this->url(array('do'=>'access'),'administratorAdministrator',true). "?sort=surname". $this->partHeadUrl; ?>">Surname</a>
                <?php endif; ?>
            </td>
            <td class="left">
                <?php if((isset($this->data['sort'])) && ($this->data['sort'] == 'otherNames')): ?>
                <a href="<?php echo $this->url(array('do'=>'access'),'administratorAdministrator',true). "?sort=otherNames". $this->partHeadUrl; ?>" class="<?php echo strtolower($this->data['order']); ?>">Other Names</a>
                <?php else: ?>
                <a href="<?php echo $this->url(array('do'=>'access'),'administratorAdministrator',true). "?sort=otherNames". $this->partHeadUrl; ?>">Other Names</a>
                <?php endif; ?>
            </td>
            <td class="right">
                <?php if((isset($this->data['sort'])) && ($this->data['sort'] == 'username')): ?>
                <a href="<?php echo $this->url(array('do'=>'access'),'administratorAdministrator',true). "?sort=username". $this->partHeadUrl; ?>" class="<?php echo strtolower($this->data['order']); ?>">Username</a>
                <?php else: ?>
                <a href="<?php echo $this->url(array('do'=>'access'),'administratorAdministrator',true). "?sort=username". $this->partHeadUrl; ?>">Username</a>
                <?php endif; ?>
            </td>
            <td class="right">
                <?php if((isset($this->data['sort'])) && ($this->data['sort'] == 'status')): ?>
                <a href="<?php echo $this->url(array('do'=>'access'),'administratorAdministrator',true). "?sort=status". $this->partHeadUrl; ?>" class="<?php echo strtolower($this->data['order']); ?>">Status</a>
                <?php else: ?>
                <a href="<?php echo $this->url(array('do'=>'access'),'administratorAdministrator',true). "?sort=status". $this->partHeadUrl; ?>">Status</a>
                <?php endif; ?>
            </td>
            <td class="right">Action</td>
          </tr>
        </thead>
        <tbody>
            <?php if($this->administrators): ?>

                    <?php foreach($this->administrators as $administrator): ?>
                      <tr>
                        <td style="text-align: center;"><input type="checkbox" name="selected[]" value="<?php echo $administrator->adminId; ?>" /></td>
                        <td class="left"><?php echo $this->escape($administrator->surname); ?></td>
                        <td class="left"><?php echo $this->escape($administrator->otherNames); ?></td>
                        <td class="right"><?php echo $this->escape($administrator->username); ?></td>
                        <td class="right"><?php echo $status = ($administrator->status) ? 'Enabled' : 'Disabled'; ?></td>
                        <td class="right">[ <a href="<?php echo $this->url(array('do'=>'update','id'=>$administrator->adminId),'administratorAdministrator',true)."?redir=".urlencode($this->requestUri()); ?>">View / Edit</a> ]</td>
                      </tr>
        <?php endforeach; ?>

	<?php else: ?>
          <tr>
            <td class="center" colspan="6">No results!</td>
          </tr>
       <?php endif; ?>
        </tbody>
      </table>
      </form>
      <?php if($this->administrators instanceof Zend_Paginator):?>
          <?php echo $this->paginationControl(
                            $this->administrators,
                            'Sliding',
                            '_paginator.phtml',
                            array('url'=>$this->url(array('do'=>'access'),'administratorAdministrator',true),
                                  'partUrl'=>$this->partPaginationUrl,
                            )
                            );
          ?>
      <?php endif ?>
  </div>
</div>
